package cn.edu.scau.cmi.zhouxinyue.Singleton;

import java.util.ArrayList;

public class General {
	private static int NumOfGeneral=5;
	private static int number=0;
	private static ArrayList<General> GeneralList=new ArrayList<General>();
	private String name=null;
	private General(String name) {
		this.name=name;
	}
	public static General NewGeneral(String name) {
		if(number<NumOfGeneral) {
			GeneralList.add(new General(name));
			number++;
			return GeneralList.get(number-1);
		}
		else {
			return null;
		}
	}
	public static ArrayList<General> getInstance() {
		return GeneralList;
	}
	public static int getmaxnumber() {
		return NumOfGeneral;
	}
	public static int getnumber() {
		return number;
	}
	public  String showname() {
		String tip;
		if(number<=NumOfGeneral) {
			tip="您已创建将军:"+name;
		}
		else {
			tip="将军数量已达到上限!!";
		}
		return tip;
	}

}
